<template>
  <div class="box">
    <!-- 头部组件 -->
    <tou></tou>

    <!-- 内容区域 -->
    <div class="text">
      <el-carousel height="460px">
        <el-carousel-item v-for="(item, index) in banner" :key="index">
          <img :src="'http://106.15.179.105:3000/' + item.imgPath" alt="" />
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="banner">
      <div class="nav">
        <p>{{ iphone }}</p>
        <div class="foot">
          <div class="zuo">
            <img
              src="http://106.15.179.105:3000/public/imgs/phone/phone.png"
              alt=""
            />
          </div>
          <div class="you">
            <div class="one" v-for="(item, index) in IPONE" :key="index" @click="$router.push('/details?productID='+item.product_id)">
              <img
                :src="'http://106.15.179.105:3000/' + item.product_picture"
                alt=""
              />
              <p class="p1">{{ item.product_name }}</p>
              <p class="p2">{{ item.product_title }}</p>
              <p class="p3">
                <span class="span1">{{ item.product_selling_price }}元</span
                ><span class="span2">{{ item.product_price }}元</span>
              </p>
            </div>
            <div class="tow">
              <p>浏览更多 》</p>
            </div>
          </div>
        </div>
      </div>
      <!-- 家电 -->
      <div class="jia">
        <p>家电<ul>
            <li @mouseover="ind=0"
                :class="{act:ind==0}">热门</li>
            <li @mouseover="ind=1"
                :class="{act:ind==1}">电视影音</li>
          </ul>
        </p>
        <div class="foot">
          <div class="zuo">
            <div class="one">
              <img src="http://106.15.179.105:3000/public/imgs/appliance/appliance-promo1.png"
                   alt="" />
            </div>
            <div class="one">
              <img src="http://106.15.179.105:3000/public/imgs/appliance/appliance-promo2.png"
                   alt="" />
            </div>
          </div>
          <div class="you">
            <div class="one"
                 v-for="(item, index) in JIA1"
                 :key="index"  v-if="ind==0" @click="$router.push('/details?productID='+item.product_id)">
              <img :src="'http://106.15.179.105:3000/' + item.product_picture"
                   alt="" />
              <p class="p1">{{ item.product_name }}</p>
              <p class="p2">{{ item.product_title }}</p>
              <p class="p3">
                <span class="span1">{{ item.product_selling_price }}元</span><span class="span2">{{ item.product_price }}元</span>
              </p>
            </div>
             <div class="one"
                 v-for="(ite,inde) in JIA2" :key="inde"
                 v-if="ind==1" @click="$router.push('/details?productID='+item.product_id)">
              <img :src="'http://106.15.179.105:3000/' + ite.product_picture"
                   alt="" />
              <p class="p1">{{ ite.product_name }}</p>
              <p class="p2">{{ ite.product_title }}</p>
              <p class="p3">
                <span class="span1">{{ ite.product_selling_price }}元</span><span class="span2">{{ ite.product_price }}元</span>
              </p>
            </div>
            <div class="tow">
              <p>浏览更多 》</p>
            </div>
          </div>
        </div>
      </div>
      <div class="pei">
        <p>配件<ul>
            <li @mouseover="inde=0"
                :class="{active:inde==0}">热门</li>
            <li @mouseover="inde=1"
                :class="{active:inde==1}">保护套</li>
            <li @mouseover="inde=2"
                :class="{active:inde==2}">充电器</li>
          </ul>
        </p>
        <div class="foot">
          <div class="zuo">
            <div class="one">
              <img src="http://106.15.179.105:3000/public/imgs/accessory/accessory-promo1.png"
                   alt="" />
            </div>
            <div class="one">
              <img src="http://106.15.179.105:3000/public/imgs/accessory/accessory-promo2.png"
                   alt="" />
            </div>
          </div>
          <div class="you">
            <div class="one"
                 v-for="(item, index) in PEI1"
                 :key="index" v-if="inde==0" @click="$router.push('/details?productID='+item.product_id)">
              <img :src="'http://106.15.179.105:3000/' + item.product_picture"
                   alt="" />
              <p class="p1">{{ item.product_name }}</p>
              <p class="p2">{{ item.product_title }}</p>
              <p class="p3">
                <span class="span1">{{ item.product_selling_price }}元</span><span class="span2">{{ item.product_price }}元</span>
              </p>
            </div>
              <div class="one"
                 v-for="(item, index) in PEI2"
                 :key="index" v-if="inde==1" @click="$router.push('/details?productID='+item.product_id)">
              <img :src="'http://106.15.179.105:3000/' + item.product_picture"
                   alt="" />
              <p class="p1">{{ item.product_name }}</p>
              <p class="p2">{{ item.product_title }}</p>
              <p class="p3">
                <span class="span1">{{ item.product_selling_price }}元</span><span class="span2">{{ item.product_price }}元</span>
              </p>
            </div>
              <div class="one"
                 v-for="(item, index) in PEI3"
                 :key="index" v-if="inde==2" @click="$router.push('/details?productID='+item.product_id)">
              <img :src="'http://106.15.179.105:3000/' + item.product_picture"
                   alt="" />
              <p class="p1">{{ item.product_name }}</p>
              <p class="p2">{{ item.product_title }}</p>
              <p class="p3">
                <span class="span1">{{ item.product_selling_price }}元</span><span class="span2">{{ item.product_price }}元</span>
              </p>
            </div>

            <div class="tow">
              <p>浏览更多 》</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 内容区域 -->

    <!-- 底部组件 -->
    <fot></fot>
  </div>
</template>

<script>
import {
  carousel,
  getPromoProduct,
  jia,
  TV,
  long,
  tao,
  cho,
  getDetailsPicture
} from '@/api/login.js'
import tou from '@/components/header.vue'
import fot from '@/components/footer.vue'
export default {
  components: { tou, fot },
  data() {
    return {
      banner: [],
      iphone: '手机',
      IPONE: [],
      JIA1: [],
      JIA2: [],
      ind: 0,
      inde: 0,
      PEI1: [],
      PEI2: [],
      PEI3: [],
    }
  },
  mounted() {
    carousel().then((res) => {
      this.banner = res.data.carousel
    })
    this.mble()
    this.jia1()
    this.jia2()
    this.lis1()
    this.lis2()
    this.lis3()
  },
  methods: {
    // 手机
    async mble() {
      let res = await getPromoProduct({ categoryName: this.iphone })

      this.IPONE = res.data.Product
    },
    async jia1() {
      let res = await jia({ categoryName: ['电视机', '空调', '洗衣机'] })
      // console.log(res)
      this.JIA1 = res.data.Product
    },
    async jia2() {
      let res = await TV({ categoryName: '电视机' })

      this.JIA2 = res.data.Product
    },
    async lis1() {
      let res = await long({
        categoryName: ['保护套', '保护膜', '充电器', '充电宝'],
      })
      console.log(res)
      this.PEI1 = res.data.Product
    },
    async lis2() {
      let res = await tao({ categoryName: '保护套' })
      console.log(res)
      this.PEI2 = res.data.Product
    },
    async lis3() {
      let res = await cho({ categoryName: '充电器' })
      console.log(res)
      this.PEI3 = res.data.Product
    },
  },
  computed: {},
}
</script>

<style scoped lang="scss">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.text {
  width: 1400px;
  margin: 20px auto;
}
.banner {
  width: 100%;
  background: #f5f5f5;
  .nav {
    width: 1400px;
    margin: 0 auto;
    height: 100%;
    // background: pink;

    p {
      font-size: 26px;
      font-weight: 100;
      padding: 10px 0px;
    }
    .foot {
      width: 100%;
      height: 100%;
      display: flex;
      .zuo {
        width: 270px;
        height: 100%;
        background: #fff;
        margin-right: 10px;
        cursor: pointer;

        img {
          width: 100%;
          height: 100%;
        }
      }
      .you {
        flex: 1;
        height: 100%;
        // background: blue;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        .one {
          z-index: 1;
          -webkit-transition: all 0.2s linear;
          transition: all 0.2s linear;
          width: 264px;
          height: 346px;
          background: #fff;
          padding: 30px;
          text-align: center;
          margin-left: 10px;
          margin-bottom: 16px;
          cursor: pointer;

          img {
            width: 124px;
            height: 146px;
          }
          .p1 {
            font-size: 18px;
            color: #333333;
            font-weight: 400;
          }
          .p2 {
            font-size: 16px;
            color: #b0b0b0;
          }
          .p3 {
            font-size: 20px;
            .span2 {
              text-decoration: line-through;
              color: #b0b0b0;
              margin: 0px 6px;
            }
            .span1 {
              color: #ff6700;
              margin: 0px 6px;
            }
          }
        }
        .tow {
          z-index: 1;
          -webkit-transition: all 0.2s linear;
          transition: all 0.2s linear;
          width: 264px;
          height: 346px;
          background: #fff;
          text-align: center;
          margin-left: 10px;
          margin-bottom: 16px;
          line-height: 346px;
          cursor: pointer;

          p {
            font-size: 24px;
          }
          p:hover {
            color: rgb(248, 128, 16);
          }
        }

        .one:hover {
          z-index: 2;
          -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          -webkit-transform: translate3d(0, -2px, 0);
          transform: translate3d(0, -2px, 0);
        }
        .tow:hover {
          z-index: 2;
          -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          -webkit-transform: translate3d(0, -2px, 0);
          transform: translate3d(0, -2px, 0);
        }
      }
    }
  }
  .jia {
    width: 1400px;
    margin: 0 auto;
    margin-top: 20px;
    p {
      font-size: 26px;
      font-weight: 100;
      padding: 10px 0px;
      display: flex;
      justify-content: space-between;
      ul {
        list-style: none;
        display: flex;
        cursor: pointer;

        li {
          font-size: 18px;
          margin: 0px 6px;
          margin-top: 10px;
          cursor: pointer;
        }
      }
    }
    .foot {
      width: 100%;
      height: 100%;
      display: flex;
      .zuo {
        width: 270px;
        height: 100%;
        margin-right: 10px;
        cursor: pointer;

        .one {
          z-index: 1;
          -webkit-transition: all 0.2s linear;
          transition: all 0.2s linear;
          width: 100%px;
          height: 100%;
          text-align: center;
          margin-bottom: 16px;
          cursor: pointer;

          img {
            width: 100%;
            height: 100%;
          }
        }
        .one:hover {
          z-index: 2;
          -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          -webkit-transform: translate3d(0, -2px, 0);
          transform: translate3d(0, -2px, 0);
        }
      }
      .you {
        flex: 1;
        height: 100%;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        .one {
          cursor: pointer;

          display: flex;
          justify-content: center;
          align-items: center;
          flex-wrap: wrap;
          z-index: 1;
          -webkit-transition: all 0.2s linear;
          transition: all 0.2s linear;
          width: 264px;
          height: 346px;
          background: #fff;
          padding: 30px;
          margin-left: 10px;
          margin-bottom: 16px;
          img {
            width: 180px;
            height: 146px;
          }
          .p1 {
            width: 100%;
            display: flex;
            justify-content: center;
            font-size: 14px;
            color: #333333;
            font-weight: 400;
          }
          .p2 {
            font-size: 16px;
            color: #b0b0b0;
          }
          .p3 {
            font-size: 18px;
            .span2 {
              text-decoration: line-through;
              color: #b0b0b0;
              margin: 0px 6px;
            }
            .span1 {
              color: #ff6700;
              margin: 0px 6px;
            }
          }
        }
        .tow {
          z-index: 1;
          -webkit-transition: all 0.2s linear;
          transition: all 0.2s linear;
          width: 264px;
          height: 346px;
          background: #fff;
          margin-left: 10px;
          margin-bottom: 16px;
          line-height: 346px;
          text-align: center;
          p {
            display: flex;
            cursor: pointer;

            justify-content: center;
          }
          p:hover {
            color: rgb(248, 128, 16);
          }
        }
        .one:hover {
          z-index: 2;
          -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          -webkit-transform: translate3d(0, -2px, 0);
          transform: translate3d(0, -2px, 0);
        }
        .tow:hover {
          z-index: 2;
          -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          -webkit-transform: translate3d(0, -2px, 0);
          transform: translate3d(0, -2px, 0);
        }
      }
    }
  }
  .pei {
    width: 1400px;
    margin: 0 auto;
    margin-top: 20px;

    p {
      font-size: 26px;
      font-weight: 100;
      padding: 10px 0px;
      display: flex;
      justify-content: space-between;
      ul {
        list-style: none;
        display: flex;
        cursor: pointer;

        li {
          font-size: 18px;
          margin: 0px 6px;
          margin-top: 10px;
          cursor: pointer;
        }
      }
    }
    .foot {
      width: 100%;
      height: 100%;
      display: flex;
      .zuo {
        width: 270px;
        height: 100%;
        margin-right: 10px;
        cursor: pointer;

        .one {
          z-index: 1;
          -webkit-transition: all 0.2s linear;
          transition: all 0.2s linear;
          width: 100%px;
          height: 100%;
          text-align: center;
          margin-bottom: 16px;
          cursor: pointer;

          img {
            width: 100%;
            height: 100%;
          }
        }
        .one:hover {
          z-index: 2;
          -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          -webkit-transform: translate3d(0, -2px, 0);
          transform: translate3d(0, -2px, 0);
        }
      }
      .you {
        flex: 1;
        height: 100%;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        cursor: pointer;

        .one {
          display: flex;
          justify-content: center;
          align-items: center;
          flex-wrap: wrap;
          z-index: 1;
          -webkit-transition: all 0.2s linear;
          transition: all 0.2s linear;
          width: 264px;
          height: 346px;
          background: #fff;
          padding: 30px;
          margin-left: 10px;
          margin-bottom: 16px;
          cursor: pointer;

          img {
            width: 180px;
            height: 146px;
          }
          .p1 {
            width: 100%;
            display: flex;
            justify-content: center;
            font-size: 14px;
            color: #333333;
            font-weight: 400;
          }
          .p2 {
            font-size: 16px;
            color: #b0b0b0;
          }
          .p3 {
            cursor: pointer;

            font-size: 18px;
            .span2 {
              text-decoration: line-through;
              color: #b0b0b0;
              margin: 0px 6px;
            }
            .span1 {
              color: #ff6700;
              margin: 0px 6px;
            }
          }
        }
        .tow {
          z-index: 1;
          -webkit-transition: all 0.2s linear;
          transition: all 0.2s linear;
          width: 264px;
          height: 346px;
          background: #fff;
          margin-left: 10px;
          margin-bottom: 16px;
          line-height: 346px;
          text-align: center;
          cursor: pointer;

          p {
            display: flex;
            justify-content: center;
            cursor: pointer;
          }
          p:hover {
            color: rgb(248, 128, 16);
          }
        }
        .one:hover {
          z-index: 2;
          -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          -webkit-transform: translate3d(0, -2px, 0);
          transform: translate3d(0, -2px, 0);
        }
        .tow:hover {
          z-index: 2;
          -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          -webkit-transform: translate3d(0, -2px, 0);
          transform: translate3d(0, -2px, 0);
        }
      }
    }
  }
}
.act {
  color: red;
  border-bottom: 2px solid #ff6700;
}
.active {
  color: red;
  border-bottom: 2px solid #ff6700;
}
</style>
